'************************************************************************************
' Copyright  2003-2005 Kathleen Dollard
'
' This software is provided 'as-is', without any express or implied warranty. In no 
' event will the author be held liable for any damages arising from the use of this
' software.
' 
' You may use this software for any purpose, including commercial applications, 
' and you may redistribute this software as part of application delivery: however, 
' this copyright notice may not be removed and you may not otherwise redistribute 
' this software directly other than providing a link to wwww.gendotnet.com. 
'
' You may alter this software to better server your needs (I'd like to hear about your 
' changes in order to make the software better). If you alter the softwre, you must  
' clearly mark it as altered and must not be misrepresented as the original software.
' nor wholly your original work.
'*************************************************************************************
'  Summary: Currently unused code that could be reused to isolate project settings. This proved to complex for most scenarios in testing.

Option Strict On
Option Explicit On 

Imports System

Namespace KADGen.CodeGenerationSupport
   Public Class ProjectSettings
      Inherits SettingsBase
      'NOTE: I used get functions rather than readonly properties with 
      '      parameters because I planned to convert this code to C#

      ' NOTE: maintaining the project settings was too much trouble for most project. 
      '       you can alter this to provide support for those files again.
      Const localNspaceName As String = "http://kadgen.com/KADGenProjectSettings.xsd"

      'Protected Friend Overrides Property Node() As System.Xml.XmlNode
      '   Get
      '      Return MyBase.Node
      '   End Get
      '   Set(ByVal Value As System.Xml.XmlNode)
      '      MyBase.Node = Value
      '      mNsmgr.AddNamespace("kp", localNspaceName)
      '   End Set
      'End Property

      'Protected Friend Function GetNamespacePrefix() As String
      '   If mnode Is Nothing Then
      '      Return "kp"
      '   Else
      '      Dim elem As Xml.XmlNode
      '      elem = mNode.SelectSingleNode("kp:Namespace", mNsmgr)
      '      Return Utility.Tools.GetAttributeOrEmpty(elem, "Prefix")
      '   End If
      'End Function

      'Protected Friend Function GetCommentStart(ByVal language As String) As String
      '   If mnode Is Nothing Then
      '      ' I deliberately left this case sensitive to ease later transition to a project file
      '      Select Case language
      '         Case "VB"
      '            Return "' "
      '         Case "CSharp"
      '            Return "/* "
      '         Case "XML"
      '            Return "<!-- "
      '         Case "StoredProc"
      '            Return "/* "
      '      End Select
      '   Else
      '      Dim elem As Xml.XmlNode
      '      elem = mNode.SelectSingleNode("kp:CommentCharacters/kp:CharacterSet[@Language='" & language & "']", mNsmgr)
      '      Return Utility.Tools.GetAttributeOrEmpty(elem, "Start")
      '   End If
      '   Return Nothing
      'End Function

      'Protected Friend Function GetCommentEnd(ByVal language As String) As String
      '   If mnode Is Nothing Then
      '      Select Case language
      '         Case "VB"
      '            Return ""
      '         Case "CSharp"
      '            Return " */"
      '         Case "XML"
      '            Return " -->"
      '         Case "StoredProc"
      '            Return " */"
      '      End Select
      '   Else
      '      Dim elem As Xml.XmlNode
      '      elem = mNode.SelectSingleNode("kp:CommentCharacters/kp:CharacterSet[@Language='" & language & "']", mNsmgr)
      '      Return Utility.Tools.GetAttributeOrEmpty(elem, "End")
      '   End If
      '   Return Nothing
      'End Function

      'Protected Friend Function GetCommentText( _
      '         ByVal genType As String) _
      '         As String
      '   Dim ret As String = ""
      '   If mnode Is Nothing Then
      '      ret = Microsoft.VisualBasic.vbCrLf & "'  "
      '      Select Case genType
      '         Case "Once"
      '            ret &= "This file is only generated if missing. Delete the file to force regeneration."
      '         Case "UntilEdited"
      '            ret &= "This file is regenerated until it's edited. Delete the file to force regeneration."
      '         Case "Always"
      '            ret &= "This file autogenerated - DO NOT EDIT THIS FILE"
      '         Case "Never"
      '            ret &= "Add an intelligent message if you figure out a way to use this"
      '         Case "Overwrite"
      '            ret &= "This file will be overwritten  DO NOT EDIT THIS FILE - YOUR EDITS WILL BE LOST"
      '      End Select
      '      ret &= Microsoft.VisualBasic.vbCrLf & Microsoft.VisualBasic.vbCrLf & _
      '            "'  NOTE: This denotes the way the file was created and it's possible the " & _
      '            Microsoft.VisualBasic.vbCrLf & _
      '            "'        generation type has since changed." & _
      '            Microsoft.VisualBasic.vbCrLf & _
      '            "'        Check the generation script for the curent state of the file." & _
      '            Microsoft.VisualBasic.vbCrLf
      '      Return ret
      '   Else
      '      Dim elem As Xml.XmlNode
      '      Dim cultureName As String = Globalization.CultureInfo.CurrentCulture.Name
      '      elem = mNode.SelectSingleNode("kp:Messages/" & genType & "Message", mNsmgr)
      '      Return Utility.Tools.GetAttributeOrEmpty(elem, cultureName)
      '   End If
      'End Function

      Protected Friend Function GetCommentStart(ByVal language As CodeGenerationSupport.OutputFileType) As String
         Return Settings.GetCommentStart(language)
      End Function

      Protected Friend Function GetCommentEnd(ByVal language As CodeGenerationSupport.OutputFileType) As String
         Return Settings.GetCommentEnd(language)
      End Function

      Protected Friend Function GetCommentText( _
               ByVal genType As CodeGenerationSupport.OutputGenType) _
               As String
         Return Settings.GetCommentText(genType)
      End Function

      Protected Friend Function GetHashExplanation() _
               As String
         Return Settings.GetHashExplanation()
         'If mnode Is Nothing Then
         '   Return "This funny number is a hash, dont change it"
         'Else
         '   Dim elem As Xml.XmlNode
         '   elem = mNode.SelectSingleNode("kp:HashSettings", mNsmgr)
         '   Return Utility.Tools.GetAttributeOrEmpty(elem, "HashExplanation")
         'End If
      End Function

      Protected Friend Function GetFullHashMarker() As String
         Return Settings.GetFullHashMarker()
         'If mnode Is Nothing Then
         '   Return "%%%###%%%"
         'Else
         '   Dim elem As Xml.XmlNode
         '   elem = mNode.SelectSingleNode("kp:HashSettings", mNsmgr)
         '   Return Utility.Tools.GetAttributeOrEmpty(elem, "HashMarker")
         'End If
      End Function

      Protected Friend Function GetSemanticHashMarker() As String
         Return Settings.GetSemanticHashMarker()
         'If mnode Is Nothing Then
         '   Return "%%%###%%%"
         'Else
         '   Dim elem As Xml.XmlNode
         '   elem = mNode.SelectSingleNode("kp:HashSettings", mNsmgr)
         '   Return Utility.Tools.GetAttributeOrEmpty(elem, "HashMarker")
         'End If
      End Function

      Protected Friend Function GetNoWSHashMarker() As String
         Return Settings.GetNoWSHashMarker()
         'If mnode Is Nothing Then
         '   Return "%%%##NoWS##%%%"
         'Else
         '   Dim elem As Xml.XmlNode
         '   elem = mNode.SelectSingleNode("kp:HashSettings", mNsmgr)
         '   Return Utility.Tools.GetAttributeOrEmpty(elem, "HashMarker")
         'End If
      End Function

      Protected Friend Function GetHeaderMarker() As String
         Return Settings.GetHeaderMarker()
         'If mnode Is Nothing Then
         '   Return "***^^^***|||***^^^***"
         'Else
         '   Dim elem As Xml.XmlNode
         '   elem = mNode.SelectSingleNode("kp:HashSettings", mNsmgr)
         '   Return Utility.Tools.GetAttributeOrEmpty(elem, "HeaderMarker")
         'End If
      End Function

   End Class
End Namespace